package com.firefly.web.controller.admin.cms;

import com.firefly.dao.dto.cms.LinkTypeDto;
import com.firefly.dao.dto.cms.LinkTypeSearchDto;
import com.firefly.web.controller.admin.ConsoleApiRestController;
import com.firefly.dao.dto.CommonDto;
import com.firefly.dao.vo.CommonListVo;
import com.firefly.dao.vo.cms.LinkTypeVo;
import com.firefly.service.command.cms.LinkTypeCommand;
import com.firefly.service.query.cms.LinkTypeQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
/**
 * @author 萤火科技
 * @since 2022-08-02 08:57:45
 */
@ConsoleApiRestController("/linktype")
public class LinkTypeController {
    private final LinkTypeQuery linkTypeQuery;
    private final LinkTypeCommand linkTypeCommand;
    @Autowired
    public LinkTypeController(LinkTypeQuery linkTypeQuery,LinkTypeCommand linkTypeCommand){
        this.linkTypeQuery = linkTypeQuery;
        this.linkTypeCommand = linkTypeCommand;
    }

    @GetMapping("/list")
    public CommonListVo getAll(LinkTypeSearchDto request) {
        return linkTypeQuery.getList(request);
    }

    @GetMapping("/detail")
    public LinkTypeVo getDetail(@Validated(CommonDto.showDetail.class) CommonDto request) {
        return linkTypeQuery.getDetail(request);
    }

    @PostMapping("/create")
    public Boolean postCreate(@Validated(LinkTypeDto.create.class) LinkTypeDto request) {
        return linkTypeCommand.create(request);
    }

    @PostMapping("/update")
    public Boolean postUpdate(@Validated(LinkTypeDto.update.class) LinkTypeDto request) {
        return linkTypeCommand.update(request);
    }

    @PostMapping("/remove")
    @Transactional
    public Boolean postRemove(@Validated(CommonDto.removeMultiple.class) CommonDto request) {
        return linkTypeCommand.remove(request);
    }
}

